package com.book.aop;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class OrderServiceLog {
	
	public OrderServiceLog() {
		System.out.println("实例化成功！");
	}

	@Pointcut(value="execution(* com.book.service.*.*(..))")  
	public void pointcut() {}
	
	@Before(value="pointcut()")
	public void beforeHandler(JoinPoint joinpoint) {
		 System.out.println(joinpoint.getSignature().getDeclaringTypeName() + "类的" + joinpoint.getSignature().getName() + "方法于" + 
				 new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "被访问。");
	 }
}
